package service.temp.job.matching.poc.listingapi.dto;

import com.google.common.collect.ImmutableMap;
import lombok.Data;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;

/**
 * SearchCondition
 *
 * @author Chao Xiong (chxiong@coupang.com)
 */
@Data
public class SearchCondition {
    private int limit = 108;
    private int start = 0;
    private String query;
    private Context context = new Context();
    private List<String> sort = Arrays.asList("SOLDOUT", "DEFAULT");
    private Map<String, GeneralFilter> filter = ImmutableMap.of("TYPE", new GeneralFilter());

    public SearchCondition(String query) {
        this.query = query;
    }

    @Data
    public static class Context {
        private String abTests = "9999_A";
        private String appVersion = "1";
        private int bundleId = 1;
        private String channel = "channel";
        private String ip = "0.0.0.0";
        private String osType = "PC";
        private String pcid = "1";
        private String sourcePage = "Home";
        private int userNo = 1;
        private String uuid = "123421312412412341241241243123";
        private String viewType = "WEB";
        private String filteredAbTests = "1";
    }

    @Data
    public static class GeneralFilter {
        private List<String> values = Collections.singletonList("PRODUCT");
        private List<GeneralFilter> generalFilters = new ArrayList<>();
        private String generalFilterType = "DefaultFilter";  // enum
        private String operator = "OR";  // enum
        private String field = "TYPE";
        private boolean exclude = false;
    }
}
